﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FTI
{
    public static partial class Extensions
    {
        public static bool IsNull<T>(this T pThis)
        {
            return pThis == null;
        }

        public static T IsNull<T>(this T pThis, T @default)
        {
            if (IsNull(pThis))
            {
                return @default;
            }
            else
            {
                return pThis;
            }
        }

        public static R IsNull<T,R>(this T pThis, R @default, Func<T,R> selector)
        {
            if (IsNull(pThis))
            {
                return @default;
            }
            else
            {
                return selector(pThis);
            }
        }

        public static bool IsNotNull<T>(this T pThis)
        {
            return !(pThis == null);
        }

        public static T IsNotNull<T>(this T pThis, T @default)
        {
            if (IsNotNull(pThis))
            {
                return pThis;
            }
            else
            {
                return @default;
            }
        }

        public static R IsNotNull<T, R>(this T pThis, R @default, Func<T, R> selector)
        {
            if (IsNotNull(pThis))
            {
                return selector(pThis);
            }
            else
            {
                return @default;
            }
        }
    }
}
